﻿using System.Windows;
using System.Windows.Controls;

namespace LightReader
{
    // Original code copied from http://www.flawlesscode.com/post/2008/03/Silverlight-2-Navigating-Between-Xaml-Pages.aspx
    // Modified by mje to remove "transition" methods
    public static class NavigationHelper
    {
        private static Grid root;

        static NavigationHelper()
        {
            root = Application.Current.RootVisual as Grid;
        }

        public static void Navigate(UserControl newPage)
        {
            UserControl oldPage = root.Children[0] as UserControl;
            root.Children.Add(newPage);
            root.Children.Remove(oldPage);
        }
    }
}
